package com.ml.mall.service.sys;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ml.mall.bean.base.ApiRestResult;
import com.ml.mall.bean.page.Page;
import com.ml.mall.bean.req.company.CompanyInviteCreateUserDto;
import com.ml.mall.bean.req.sys.*;
import com.ml.mall.bean.res.sys.SysUserRes;
import com.ml.mall.bean.res.sys.UserQueryInfoRes;
import com.ml.mall.entity.sys.SysPermission;
import com.ml.mall.entity.sys.SysUser;

import java.util.List;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author kyyang
 * Created 2021-01-05
 */
public interface SysUserService extends IService<SysUser> {

    boolean refreshTokenIsValid(String oldToken);

    String loginForToken(SysUser user);

    SysUser findByAccount(String userName);

    SysUser getById(Long userId);

    int save(SysUserDto sysUserDto);

    //为自己公司添加新账号：dzh
    int addNewUser(SysUserDto sysUserDto);

    Page<SysUserRes> selectAccByPage(SysUserQueryDto dto);

    int editInfo(SysUserEditDto sysUserEditDto);

    int editResetpwd(SysUser sysUser);

    int editPwd(SysUser byAccount, SysUserEditPwdDto sysUserEditPwdDto);

    void logout();

    /**
     * @description: 获取当前用户权限
     * @author kyyang
     * @date 2021/1/21 15:09
     * @version 1.0
     */
    List<SysPermission> accountPermissionsQuery(SysPermissionsDto sysPermissionsDto);

    /**
     * @description: 获取当前用户菜单
     * @author kyyang
     * @date 2021/1/21 19:09
     * @version 1.0
     */
    List<SysPermission> accountMenuQuery();

    /**
     * @description    :查询单个用户
     * @author         :zxm
     * @date           :2021/5/18
    **/
    UserQueryInfoRes queryOneSysUser(SysUserQueryOneDto dto);

    /**
     * @description    :用户根据邀请创建账户
     * @author         :pl
     * @date           :2021/6/15
     **/
    int createUserByInvite(CompanyInviteCreateUserDto dto);

    /**
     * @description    :更改归属公司
     * @author         :pl
     * @date           :2021/6/16
     **/
    int accountChangeCompany(SysUserChangeCompanyDto dto);


    /**
     * @description: 忘记密码发送邮件
     * @author kyyang
     * @date 2021/8/2 22:47
     * @version 1.0
     * @param sysUserForgetPasswdEmail
     */
    void forgetPasswd2Email(SysUserForgetPasswdEmail sysUserForgetPasswdEmail);

    /**
     * @description: 忘记密码
     * @author kyyang
     * @date 2021/8/2 22:59
     * @version 1.0
     */
    ApiRestResult forgetPasswd(SysUserForgetPasswdDto sysUserForgetPasswdDto);

    /**
     * @description: 查询重名用户
     * @author kyyang
     * @date 2021/8/19 23:23
     * @version 1.0
     */
    List<SysUser> queryByName(SysQuerySameNameDto sysQuerySameNameDto);

    /**
     * 查询本公司用户
     * @param dto
     * @return
     */
    Page<SysUserRes> selectSelfCompanyAccByPage(SysUserQueryDto dto);

    /**
     * 存储用户与用户角色信息
     * @param sysUser
     * @return
     */
    boolean saveUserAndRoleUser(SysUser sysUser);

    /**
     * 根据邮件获取用户
     * @param acc
     * @return
     */
    SysUser selectAccByEmail(String acc);

//    boolean resetPassword(String email, String code);
}
